# 读取csv文件注册信息
import csv

import requests


class CheckTest:
    def __init__(self):
        self.url = "http://129.211.129.101:9006/user/check_vaild.do"

    def check_test(self):
        file1 = open("../data/register_data.csv", "r")
        file2 = open("../data/register_res.csv", "w")
        table = csv.reader(file1)
        check_info = {}
        for row in table:
            check_info["str"] = row[0]
            check_info["type"] = row[1]
            s = requests.session()
            res = s.post(self.url, data=check_info).text
            r = res.find(row[2])
            if r > 0:
                file2.write(f"{row[0]},{row[1]},{row[2]},测试通过\n")
            else:
                file2.write(f"{row[0]},{row[1]},{row[2]},测试不通过\n")
            print(res)
        file2.close()


if __name__ == '__main__':
    CheckTest().check_test()
